package com.google.code.ptrends.excel.entities;

public class Worksheet {

	private String name;
	private int fHashCode;

	public Worksheet(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public int hashCode() {
		if (fHashCode == 0) {
			if (name == null) 
				fHashCode = 7 + 23 * "".hashCode();
			else 
				fHashCode = 11 + 23 * this.name.hashCode();			
		}
		
		return fHashCode;
	}

	@Override
	public boolean equals(Object arg0) {
		boolean result = false;
		
		if (arg0 == null)
			return result;
		
		if (!(arg0 instanceof Worksheet))
			return result;
		
		Worksheet obj = (Worksheet) arg0;
		
		if (name != null)
			result = name.equals(obj.getName());
		else
			result = obj.getName() == null;
		
		return result;
	}
	
	@Override
	public String toString() {
		return this.name;
	}
}
